package com.jjh.util;

import java.util.List;
import java.util.Objects;

/**
 * 对分页的封装
 */
public class PageBody {
    /**
     * 总条数
     */
    private int total;
    /**
     * 当前的页数
     */
    private int currntPage;
    /**
     * 当前每页的尺寸
     */
    private int size;
    /**
     * 总页数
     */
    private int pageSize;
    /**
     * 结果集
     */
    private List<Object> results;

    public PageBody() {
    }

    public PageBody(int total, int currntPage, int size, int pageSize, List<Object> results) {
        this.total = total;
        this.currntPage = currntPage;
        this.size = size;
        this.pageSize = pageSize;
        this.results = results;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
        //设置总页数
        if(size!=0){
            this.pageSize = total / size +1;
        }

    }

    public int getCurrntPage() {
        return currntPage;
    }

    public void setCurrntPage(int currntPage) {
        this.currntPage = currntPage;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getPageSize() {
        return pageSize;
    }

//    public void setPageSize(int pageSize) {
//        this.pageSize = pageSize;
//    }

    public List<Object> getResults() {
        return results;
    }

    public void setResults(List<Object> results) {
        this.results = results;
    }

    @Override
    public String toString() {
        return "PageBody{" +
                "total=" + total +
                ", currntPage=" + currntPage +
                ", size=" + size +
                ", pageSize=" + pageSize +
                ", results=" + results +
                '}';
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;

    }
}
